﻿@using System.Globalization
@using MileageStats.Domain.Models
@using MileageStats.Web.Models
@model List<ReminderSummaryModel>
@{
    var reminders = new SelectedItemList<ReminderSummaryModel>(Model);
    
    reminders.SelectedItem = (Html.RouteValue("id") != string.Empty) 
        ? reminders.FirstOrDefault(x => x.ReminderId.ToString(CultureInfo.InvariantCulture) == Html.RouteValue("id")) 
        : reminders.FirstOrDefault();
        
    var selectedId = (reminders.SelectedItem == null) ? -1 : reminders.SelectedItem.ReminderId;
}
<div class="list nav">
    @foreach (var item in reminders)
    {
        var selectedClass = item.ReminderId == selectedId ? "selected" : string.Empty;
        var overdueClass = item.IsOverdue ? "overdue" : string.Empty;
        <a class="list-item @(selectedClass) @(overdueClass)" href="@Url.Action("Details", "Reminder", new { id = item.ReminderId })">
            <h1>@item.Title</h1>
            <p class="title">Due @item.DueOnFormatted
            </p>            
        </a>
    }
</div>
